<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/7/22
  Time: 13:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <%@include file="../../../../resources/inc/head.jsp" %>
</head>
<body>

<div class="layui-fluid">
    <expect-x:tip tipMessage="标识“*”的选项为必填项，其余为选填项。;请按提示信息填写每一个字段"/>

    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto option-bar">
            <div class="layui-collapse ">
<%--                <div class="layui-colla-item">--%>
<%--                    <h2 class="layui-colla-title">展开搜索</h2>--%>
<%--                    <div class="layui-colla-content">--%>
<%--                        <div class="layui-form-item">--%>
<%--                            <div class="layui-inline">--%>
<%--&lt;%&ndash;                                <label class="layui-form-label">请求方式</label>&ndash;%&gt;--%>
<%--                                <expect-x:dictSelect field="requestType" verify="false" typeGroupCode="method_type" />--%>
<%--                            </div>--%>
<%--                            <div class="layui-inline">--%>
<%--                                <div class="layui-input-block">--%>
<%--                                    <input type="text" name="userName" placeholder="请输入用户名" autocomplete="off" class="layui-input">--%>
<%--                                </div>--%>
<%--                            </div>--%>
<%--                            <div class="layui-inline">--%>
<%--                                <button  class="layui-btn" lay-submit lay-filter="Type-serch">--%>
<%--                                    搜索--%>
<%--                                </button>--%>
<%--                            </div>--%>
<%--                        </div>--%>
<%--                    </div>--%>

<%--                </div>--%>
            </div>

        </div>

        <div class="layui-card-body">
            <table id="oauthManager" lay-filter="oauthManager"></table>
            <script type="text/html" id="optionToolbar">
                <div class="layui-btn-container">
                    <shiro:hasPermission name="Expect-X:system:log:create"><button class="layui-btn layui-btn-sm" lay-event="add">新增  </button></shiro:hasPermission>
                    <shiro:hasPermission name="Expect-X:system:log:delete"><button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="dels"id="dels">批量删除</button></shiro:hasPermission>
                </div>
            </script>
            <script type="text/html" id="optionBar">
                {{# if(d.merchantOauth!=null&&d.merchantOauth.status==0){ }}
                  <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="oauth">进入初审流程</a>
                {{#  }}}
                {{# if(d.merchantOauth!=null&&d.merchantOauth.status==1){ }}
                    <a class="layui-btn layui-btn-xs" lay-event="oauth">各大支付商审核流程</a>
                    <a class="layui-btn layui-btn-warm layui-btn-xs" lay-href="<%=basePath%>manager/merchant/applicationConfig/index/{{d.merchantNo}}.html" >应用配置</a>
                {{#  }}}

<%--         <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>  --%>
            </script>
            <script type="text/html" id="isAuth">
                {{
               d.merchantOauth==null?'未审核': (d.merchantOauth.status=='1' || d.merchantOauth.status=='0')?'审核中':d.merchantOauth.status=='2'?'审核成功':d.merchantOauth.status=='3'?'审核失败 原因: '+d.merchantOauth.oauthRemark:''
<%--                d.isAuth==1?'通过':d.isAuth==0?'未审核':''--%>
                }}
            </script>
            <script type="text/html" id="gmtStartTime">
                {{#
                var date = new Date();
                date.setTime(d.gmtModified);
                return date.Format("yyyy-MM-dd hh:mm:ss");
                }}
            </script>

        </div>
    </div>
</div>

<%@include file="../../../../resources/inc/footer.jsp" %>
<script>
    layui.config({
        base: '<%=basePath%>resources/lib/layuiAdmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table'], function () {
        var $ = layui.$
            , form = layui.form
            , table = layui.table;

        table.render({
            elem: '#oauthManager',
            url: '<%=basePath%>manager/merchant/oauth/page.html',
            cols: [[
                {type: 'checkbox',fixed:'left'},
                {field: 'id', width: 60, title: 'ID', sort: true}
                , {field: 'email', title: '邮箱'}
                ,{field: 'company',  title: '公司名'}
                , {field: 'leadingCadre', title: '负责人'}
                , {field: 'mobile', title: '手机号'}
                , {field: 'qq', title: 'QQ'}
                , {field: 'isAuth', title: '是否审核', templet: "#isAuth"}
                , {field: 'startTime', title: '操作时间', sort: true, templet: "#gmtStartTime"}
                , {title: "操作", width: 240, align: "left", fixed: "right", toolbar: "#optionBar"}

            ]],
            page: !0,
            limit: 10,
            height: "full-130",
            text: {none:"暂无可显示数据"},
            response: {
                statusCode: 200
            }
        });
        table.on("tool(oauthManager)", function (e) {
      if ("oauth" === e.event) {
            $(e.tr);
            var btnTitle="认证";
            console.log(e.data.merchantOauth)
            //alert(e.data.status==0+"   "+e.data.status)
            if(e.data.merchantOauth.status==0){
                btnTitle="设初审通过"
            }
          if(e.data.merchantOauth.status==1){
              btnTitle="进入各大支付商审核"
          }
            var dialog = new UtilClass.LayerDialog({
                title: e.data.company+"认证",
                btns: [btnTitle,'拒绝'],
                content: "<%=basePath%>manager/merchant/oauth/oauth/" + e.data.id + ".html"
            });
            dialog.layerShow();
        }else if("applicationConfig"===e.event){
            var dialog = new UtilClass.LayerDialog({
                title: e.data.company+"应用管理",
                btns: [],
                content: "<%=basePath%>manager/merchant/applicationConfig/index/" + e.data.merchantNo + ".html"
            });
            dialog.layerShow();
        }
    });

        //监听搜索
        form.on('submit(Type-serch)', function (data) {
            var field = data.field;
            field.page=1;
            table.reload('oauthManager', {
                where: field
            });
        });


    });
    function oauth(e) {

    }

</script>
</body>
</html>

